| Plant | Flowers | Date | lon | lat | ele | Year |
|---|---|---|---|---|---|---|
| Glossoloma oblongicalyx | 4 | 2015-10-19 | -78.59093 | 0.130838 | 2270 | 1445238000y 0m 0d 0H 0M 0S |
| Gasteranthus quitensis | 2 | 2016-10-17 | -78.59770 | 0.120070 | 1940 | 1476687600y 0m 0d 0H 0M 0S |
| Kohleria affinis | 1 | 2016-12-13 | -78.59534 | 0.126746 | 2110 | 1481616000y 0m 0d 0H 0M 0S |
| Columnea ciliata | 3 | 2014-02-27 | -78.59934 | 0.116682 | 1960 | 1393488000y 0m 0d 0H 0M 0S |
| Columnea medicinalis | 1 | 2014-04-23 | -78.59372 | 0.128700 | 2130 | 1398236400y 0m 0d 0H 0M 0S |
| Drymonia teuscheri | 3 | 2016-07-28 | -78.59245 | 0.129393 | 2200 | 1469689200y 0m 0d 0H 0M 0S |
Let’s start with a traditional randomization test to get everyone comfortable with the essential result. For each random draw, calculate the mean niche overlap in hummingbird usage. Species can only bloom at site which they occur. Mantains plant abundance.
Equal probability of flowering at anytime.
## sink("model/threshold_baseline.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x]]
##
## #Residuals
## discrepancy[x] <- abs(Y[x] - p[x])
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-abs(Ynew[x] - p[x])
## }
##
##
## #Sum discrepancy
## fit<-sum(discrepancy)/Nobs
## fitnew<-sum(discrepancy.new)/Nobs
##
## #Prediction
##
## for(x in 1:Npreds){
## #predict value
##
## #Observation - probability of flowering
## prediction[x] ~ dbern(p_new[x])
## logit(p_new[x])<-alpha[PredPlant[x]]
##
## #predictive error
## pred_error[x] <- abs(Ypred[x] - p_new[x])
## }
##
##
## #Predictive Error
## fitpred<-sum(pred_error)/Npreds
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
##
## #Intercept flowering probability
## alpha[j] ~ dnorm(0,0.386)
##
## }
##
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 3585
## Unobserved stochastic nodes: 4275
## Total graph size: 20054
##
## Initializing model
Equal probability of flowering per elevation
## sink("model/threshold_baseline_site.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x],Site[x]]
##
## #Residuals
## discrepancy[x] <- abs(Y[x] - p[x])
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-abs(Ynew[x] - p[x])
## }
##
##
## #Sum discrepancy
## fit<-sum(discrepancy)/Nobs
## fitnew<-sum(discrepancy.new)/Nobs
##
## #Prediction
##
## for(x in 1:Npreds){
## #Observation - probability of flowering
## prediction[x] ~ dbern(p_new[x])
## logit(p_new[x])<-alpha[NewPlant[x],NewSite[x]]
##
## #predictive error
## pred_error[x] <- abs(Ypred[x] - p_new[x])
## }
##
##
## #Predictive Error
## fitpred<-sum(pred_error)/Npreds
##
## #Priors
##
## #Species level priors
## for (i in 1:Plants){
## for(j in 1:Sites){
##
## #Intercept flowering probability
## alpha[i,j] ~ dnorm(0,0.386)
##
## }
## }
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 3585
## Unobserved stochastic nodes: 4350
## Total graph size: 24695
##
## Initializing model
Equal probability of flowering per elevation
## sink("model/threshold_baseline_site_month.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x],Site[x],Month[x]]
##
## #Residuals
## discrepancy[x] <- abs(Y[x] - p[x])
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-abs(Ynew[x] - p[x])
## }
##
##
## #Sum discrepancy
## fit<-sum(discrepancy)/Nobs
## fitnew<-sum(discrepancy.new)/Nobs
##
## #Prediction
##
## for(x in 1:Npreds){
## #Observation - probability of flowering
## prediction[x] ~ dbern(p_new[x])
## logit(p_new[x])<-alpha[NewPlant[x],NewSite[x],NewMonth[x]]
##
## #predictive error
## pred_error[x] <- abs(Ypred[x] - p_new[x])
## }
##
##
## #Predictive Error
## fitpred<-sum(pred_error)/Npreds
##
## #Priors
##
## #Species level priors
## for (i in 1:Plants){
## sigma_month[i] ~ dgamma(0.0001,0.0001)
## for(j in 1:Sites){
## alpha_site[i,j] ~ dnorm(0,0.386)
## for(k in 1:Months){
## #Intercept flowering probability
## alpha[i,j,k] ~ dnorm(alpha_site[i,j],sigma_month[i])
## }
## }
## }
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 3585
## Unobserved stochastic nodes: 5445
## Total graph size: 33478
##
## Initializing model
## sink("model/threshold_attraction.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x],Site[x]] + e[Plant[x],Site[x],Month[x]]
##
## #Residuals
## discrepancy[x] <- abs(Y[x] - p[x])
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-abs(Ynew[x] - p[x])
## }
##
## #Sum discrepancy
## fit<-sum(discrepancy)/Nobs
## fitnew<-sum(discrepancy.new)/Nobs
##
## #Prediction
##
## for(x in 1:Npreds){
## #predict value
##
## #Observation - probability of flowering
## prediction[x] ~ dbern(p_new[x])
## logit(p_new[x])<- alpha[NewPlant[x],NewSite[x]] + e[NewPlant[x],NewSite[x],NewMonth[x]]
##
## #predictive error
## pred_error[x] <- abs(Ypred[x] - p_new[x])
## }
##
## #Predictive Error
## fitpred<-sum(pred_error)/Npreds
##
## #########################
## #autocorrelation in error
## #########################
##
## #For each of observation
## for(y in 1:Sites){
## for(x in 1:Months){
## e[1:Plants,y,x] ~ dmnorm(zeros,tauC[,])
## }
## }
##
## ##covariance among similiar species
## for(i in 1:Plants){
## for(j in 1:Plants){
## C[i,j] = exp(-lambda_cov * D[i,j])
## }
## }
##
## ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
## vCov = omega*C[,] + (1-omega) * I
## tauC=inverse(vCov*gamma)
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
## for(k in 1:Sites){
## #Intercept flowering probability
## alpha[j,k] ~ dnorm(0,0.386)
## } }
##
## #Autocorrelation priors
## gamma ~ dunif(0,5)
##
## #Strength of covariance decay
## lambda_cov ~ dunif(0,5)
## omega = 1
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 3585
## Unobserved stochastic nodes: 4424
## Total graph size: 35305
##
## Initializing model
## sink("model/threshold_repulsion.jags")
## cat("
## model {
##
## for (x in 1:Nobs){
##
## #Observation of a flowering plant
## Y[x] ~ dbern(p[x])
## logit(p[x]) <- alpha[Plant[x],Site[x]] + e[Plant[x],Site[x],Month[x]]
##
## #Residuals
## discrepancy[x] <- abs(Y[x] - p[x])
##
## #Assess Model Fit
## Ynew[x] ~ dbern(p[x])
## discrepancy.new[x]<-abs(Ynew[x] - p[x])
## }
##
##
## #Sum discrepancy
## fit<-sum(discrepancy)/Nobs
## fitnew<-sum(discrepancy.new)/Nobs
##
## #Prediction
##
## for(x in 1:Npreds){
## #predict value
##
## #Observation - probability of flowering
## prediction[x] ~ dbern(p_new[x])
## logit(p_new[x])<- alpha[NewPlant[x],NewSite[x]] + e[NewPlant[x],NewSite[x],NewMonth[x]]
##
## #predictive error
## pred_error[x] <- abs(Ypred[x] - p_new[x])
## }
##
## #Predictive Error
## fitpred<-sum(pred_error)/Npreds
##
## #########################
## #autocorrelation in error
## #########################
##
## #For each of observation
## for(x in 1:Months){
## for(y in 1:Sites){
## e[1:Plants,y,x] ~ dmnorm(zeros,tauC[,])
## }
## }
## ##covariance among similiar species
## for(i in 1:Plants){
## for(j in 1:Plants){
## C[i,j] = exp(-lambda_cov * D[i,j])
## }
## }
##
## ## Covert variance to precision for each parameter, allow omega to shrink to identity matrix
## vCov = omega*C[,] + (1-omega) * I
## tauC=vCov*gamma
##
## #Priors
##
## #Species level priors
##
## for (j in 1:Plants){
## for(k in 1:Sites){
## #Intercept flowering probability
## alpha[j,k] ~ dnorm(0,0.386)
## }
## }
##
## #Autocorrelation priors
## gamma ~ dunif(0,5)
##
## #Strength of covariance decay
## lambda_cov ~ dunif(0,5)
## omega = 1
## }
## ",fill=TRUE)
##
## sink()
## Compiling model graph
## Resolving undeclared variables
## Allocating nodes
## Graph information:
## Observed stochastic nodes: 3585
## Unobserved stochastic nodes: 4424
## Total graph size: 35304
##
## Initializing model
# One example
Glossoloma purpureum
## # A tibble: 5 x 2
## Model p
## <chr> <dbl>
## 1 baseline 0.542
## 2 baseline_site 1
## 3 baseline_site_month 1
## 4 interaction_attraction 1
## 5 interaction_repulsion 1
Without baseline
## # A tibble: 4 x 2
## Model p
## <chr> <dbl>
## 1 baseline_site 1
## 2 baseline_site_month 1
## 3 interaction_attraction 1
## 4 interaction_repulsion 1
| Model | mean | lower | upper |
|---|---|---|---|
| baseline_site | 0.2015586 | 0.1964144 | 0.2068303 |
| baseline_site_month | 0.1853191 | 0.1756552 | 0.1953314 |
| interaction_repulsion | 0.1826840 | 0.1757859 | 0.1894327 |
| interaction_attraction | 0.1798205 | 0.1725367 | 0.1874824 |
| Model | mean | lower | upper |
|---|---|---|---|
| baseline | 0.2179920 | 0.2111130 | 0.2255539 |
| baseline_site | 0.2004830 | 0.1938548 | 0.2074097 |
| baseline_site_month | 0.1940599 | 0.1858530 | 0.2025038 |
| interaction_attraction | 0.1930091 | 0.1851200 | 0.2007233 |
| interaction_repulsion | 0.1926848 | 0.1848993 | 0.2004418 |
Columnea medicinialis v Columnea strigosa which have strong overlap in visitors
Dint["Columnea medicinalis","Columnea strigosa"]
## [1] 0.2096899
Logit E
inv.logit E
## # A tibble: 2 x 4
## # Groups: Model [2]
## Model Var1 Var2 Correlation_E
## <chr> <fct> <fct> <dbl>
## 1 interaction_attraction Columnea medicinal… Columnea strigo… 0.862
## 2 interaction_repulsion Columnea medicinal… Columnea strigo… -0.612
## # A tibble: 5 x 4
## # Groups: Model [5]
## Model Var1 Var2 Correlation_P
## <chr> <fct> <fct> <dbl>
## 1 baseline Columnea medicinal… Columnea strigo… NA
## 2 baseline_site Columnea medicinal… Columnea strigo… 0.233
## 3 baseline_site_month Columnea medicinal… Columnea strigo… 0.248
## 4 interaction_attraction Columnea medicinal… Columnea strigo… 0.244
## 5 interaction_repulsion Columnea medicinal… Columnea strigo… 0.218
## # A tibble: 5 x 4
## # Groups: Model [5]
## Model Var1 Var2 Correlation_Ynew
## <chr> <fct> <fct> <dbl>
## 1 baseline Columnea medicina… Columnea strig… NA
## 2 baseline_site Columnea medicina… Columnea strig… 0.233
## 3 baseline_site_month Columnea medicina… Columnea strig… 0.159
## 4 interaction_attracti… Columnea medicina… Columnea strig… 0.173
## 5 interaction_repulsion Columnea medicina… Columnea strig… 0.193
Flowering patterns
Model Fit and Prediction Fit
Comparison of the attraction and repulsion
Overlay
Predictions from the best model
Supplamental figures